var a = getApp();

Page({
    data: {
        language: "",
        rewardDetail: {},
        name: "",
        type: "",
        api: ""
    },
    onLoad: function(a) {
        this.setData({
            id: a.id,
            type: a.name
        }), this.initData(this.data.type), this.getData();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    initData: function(a) {
        switch (a) {
          case "teamManagement":
            this.setData({
                api: "plugin.mryt.api.team-manage.details",
                name: "获得销售佣金会员"
            });
            break;

          case "team":
            this.setData({
                api: "plugin.mryt.api.team.details",
                name: "新进会员"
            });
            break;

          case "thanks":
            this.setData({
                api: "plugin.mryt.api.thanksgiver.details",
                name: "新进会员"
            });
            break;

          case "education":
            this.setData({
                api: "plugin.mryt.api.train.details",
                name: "下级会员"
            });
            break;

          case "immediate":
            this.setData({
                api: "plugin.mryt.api.direct-award.details",
                name: "新进会员"
            });
            break;

          case "tier":
            this.setData({
                api: "plugin.mryt.api.tier.details",
                name: "新进会员"
            });
            break;

          default:
            this.setData({
                api: "plugin.mryt.api.team-manage.details",
                name: "获得销售佣金会员"
            });
        }
    },
    getData: function() {
        var t = this, e = a.getNetAddresss(this.data.api);
        e += "&award_id=" + this.data.id, a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 === e.result ? t.setData({
                    rewardDetail: e.data
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    }
});